package com.tx.admin.security.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import com.tx.admin.security.service.MailService;

@Component
class MailServiceImpl implements MailService{

	 @Autowired
	 private JavaMailSender mailSender;
	 
	  @Value("${spring.mail.username}")
	  private String sender; //读取配置文件中的参数

	
	@Override
	public void sendMail(String toUser, String email) {
		// TODO Auto-generated method stub
		   SimpleMailMessage message = new SimpleMailMessage();
	        message.setFrom(sender);
	        message.setTo(toUser); //自己给自己发送邮件
	        message.setSubject("邮件");
	        message.setText(email);
	        mailSender.send(message);
	}


	@Override
	public void sendAutdCode(String toUser, String email) {
		// TODO Auto-generated method stub
		   SimpleMailMessage message = new SimpleMailMessage();
	        message.setFrom(sender);
	        message.setTo(toUser); //自己给自己发送邮件
	        message.setSubject("密码找回");
	        message.setText(email);
	        mailSender.send(message);
	}

}
